package com.mnemonic.views;

import java.awt.CardLayout;

import javax.swing.JPanel;

/**
 * 中间的可操作区域的封装
 * 
 * @author lifeng
 * @date 2021/05/12
 */
public class MainPanel extends JPanel {

    private static final long serialVersionUID = 1L;

    private CardLayout layout = new CardLayout(10, 10);
    private LevelPanel levelPanel;
    private ArchivePanel archivePanel;
    private PlayerPanel playerPanel;
    private PlayPanel playPanel;

    public MainPanel() {
        this.setLayout(layout);

        // 创建各个界面
        levelPanel = new LevelPanel();
        archivePanel = new ArchivePanel();
        playerPanel = new PlayerPanel();
        playPanel = new PlayPanel();

        // 添加到卡片布局的面板中
        this.add(levelPanel, "level");
        this.add(archivePanel, "archive");
        this.add(playerPanel, "player");
        this.add(playPanel, "play");

        // 显示指定的
        this.showPlayPanel();
    }

    /**
     * 点击 “难度”显示的界面
     */
    public void showLevelPanel() {
        levelPanel.init();
        layout.show(this, "level");
    }

    /**
     * 点击 “对战”显示的界面
     */
    public void showPlayPanel() {
        playPanel.init();
        layout.show(this, "play");
    }

    /**
     * 点击 “玩家”显示的界面
     */
    public void showPlayerPanel() {
        playerPanel.init();
        layout.show(this, "Player");
    }

    /**
     * 点击 “归档”显示的界面
     */
    public void showArchivePanel() {
        archivePanel.init();
        layout.show(this, "archive");
    }
}
